import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.io.ClassPathResource;

/**
 * Created with IntelliJ IDEA
 * Description
 * User：chenshu
 * Date：2024-03-12
 * Time：16:36
 */
public class Application {
    public static void main(String[] args) {
//        ApplicationContext context
//                = new ClassPathXmlApplicationContext("spring-config.xml");

        BeanFactory context
                = new XmlBeanFactory(new ClassPathResource("spring-config.xml"));

        //1.根据一个String参数获取bean
        UserBean user1 = (UserBean)context.getBean("user1");
        UserBean user1Test = (UserBean)context.getBean("user1");
        UserBean user2 = (UserBean)context.getBean("user2");

        System.out.println("user1：" + user1);
        System.out.println("user1Test：" + user1Test);
        System.out.println("user2：" + user2);
        //2.根据一个Class 参数获取bean
        //UserBean user = context.getBean(UserBean.class);


    }
}
